jQuery(document).ready(function () {
	// load message, no software yet
	jQuery('#ed_toolbar_vfb-software-requested').parent().append('<span class="software-requested-list">No software has been selected.</span>');
	
	jQuery('.request-input').bind("blur", function(){
		// cylce through all the inputs and for each that has a number, put it in the prep'd string
		
		if (jQuery(this).val() == "" || jQuery(this).val() == "0") {
			jQuery(this).removeClass('software-in').addClass('software-out');
		}
		else {
			// store software details in array
			jQuery(this).removeClass('software-out').addClass('software-in');
		}
		
		jQuery('#software_request').find('input.software-out').css('backgroundColor','transparent');
		jQuery('#software_request').find('input.software-in').css('backgroundColor','#BBE8BB');
		
		var myStr = '';
		var myStrHtml = '';
		
		jQuery('#software_request').find('input.software-in').each(function(index) {
		
			myStr = myStr + '[ Software: ' + jQuery(this).parent().siblings('.request-software').find('a').text() + ', Cost: ' + jQuery(this).parent().siblings('.request-fees').text() + ', No. Licenses: ' + jQuery(this).val() + ' ] ';
		
			myStrHtml = myStrHtml + '<ul><li><strong>Software:</strong> ' + jQuery(this).parent().siblings('.request-software').find('a').text() + '</li><li><strong>Cost:</strong> ' + jQuery(this).parent().siblings('.request-fees').text() + '</li><li><strong>No. Licenses:</strong> ' + jQuery(this).val() + '</li></ul>';
		});
		
		jQuery('#vfb-software-requested').val(myStr);
		
		jQuery('.software-requested-list').remove();
		
		if (myStrHtml == '') {
			// load message, no software yet
			jQuery('#ed_toolbar_vfb-software-requested').parent().append('<span class="software-requested-list">No software has been selected.</span>');
		}
		else {
			// add prep'd string to a dynamically created div, then put the div in the form.
			jQuery('#ed_toolbar_vfb-software-requested').parent().append('<span class="software-requested-list">' + myStrHtml + '</span>');
		}
	    
	});
	
});